package com.yunxi.service.dubboService.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yunxi.model.order.OrderModifyApply;
import com.yunxi.model.order.RetailMonthlyPlan;
import com.yunxi.order.pojo.*;
import com.yunxi.order.service.RetailMonthlyPlanDubboService;
import com.yunxi.service.localService.RetailMonthlyPlanService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

public class RetailMonthlyPlanDubboServiceImpl implements RetailMonthlyPlanDubboService {

    private final Logger logger = LoggerFactory.getLogger(RetailMonthlyPlanDubboServiceImpl.class);

    @Autowired
    RetailMonthlyPlanService retailMonthlyPlanService;

    @Override
    public boolean save(RetailMonthlyPlanSaveReqVO vo) {
        return false;
    }

    @Override
    public boolean submit(RetailMonthlyPlanSubmitReqVO vo) {
        return false;
    }

    @Override
    public boolean verify(RetailMonthlyPlanVerifyReqVO vo) {
        return false;
    }

    @Override
    public List<RetailMonthlyPlanQueryRespVO> queryRetailMonthlyPlanForDownload(RetailMonthlyPlanQueryReqVO vo) {
        return null;
    }

    @Override
    public List<RetailMonthlyPlanQueryRespVO> queryRetailMonthlyPlan(RetailMonthlyPlanQueryReqVO vo, int pageNum, int pageSize) {
        return null;
    }

    @Override
    public boolean modifyRetailMonthlyPlan(RetailMonthlyPlanModifyReqVO vo) {
        QueryWrapper qw = new QueryWrapper();
        qw.eq("MONTHLY_PLAN_ID", vo.getMonthlyPlanId());

        RetailMonthlyPlan retailMonthlyPlan = new RetailMonthlyPlan();
        BeanUtils.copyProperties(vo,retailMonthlyPlan);

        boolean isSuccess = retailMonthlyPlanService.update(retailMonthlyPlan, qw);

        if (isSuccess) {
            return true;
        } else {
            logger.info("渠道商目标计划修改失败！");
            throw new RuntimeException("渠道商目标计划修改失败！");
        }
    }
}
